/*
 * @Author: wwssaabb
 * @Date: 2021-07-12 17:27:41
 * @LastEditTime: 2021-07-13 15:12:38
 * @FilePath: \demo\blog_demo\model\article.js
 */

const mongoose=require('mongoose')


const Article = mongoose.model('article',new mongoose.Schema({
  title:{
    type:String,
    minlength:4,
    maxlength:20,
    required:[true,'请填写文章标题']
  },
  author:{
    type:mongoose.Schema.Types.ObjectId,
    ref:'user',
    required:[true,'请填写文章作者']
  },
  publishDate:{
    type:Date,
    default: Date.now,
  },
  cover:{
    type:String,
    default:null,
  },
  content:{
    type:String,
    required:[true,'请填写文章内容']
  }
}))

/* Article.create({
  title:'JavaScript基础一：基本介绍',
  author:'讲师1',
  publishDate:'2021-7-1',
  cover:null,
  content:'对不起啊，我没有资格骂你神经病，毕竟我不是兽医。',
}) */


module.exports=Article